package com.wei.czz.common.dto.store;

import com.wei.czz.framework.store.entity.StoreEntity;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wyw
 * date: 2023-12-14 15:08:35
 * className: StoreViewDto
 * version: 1.0
 * description:
 */
@Getter
@Setter
@Accessors(chain = true)
public class StoreViewDto extends StoreDto {

    /**
     * 省份名称
     */
    private String addressProvinceName;

    /**
     * 城市名称
     */
    private String addressCityName;

    /**
     * 区县名称
     */
    private String addressDistrictName;

    /**
     * 街道名称
     */
    private String addressStreetName;

    /**
     * 经营大类名称
     */
    private String mainClassName;

    /**
     * 经营小类名称
     */
    private String subClassName;

    /**
     * 商店基础数据封装
     * @param store 商店对象
     * @return 封装结果
     */
    public static StoreViewDto map(StoreEntity store) {
        StoreViewDto storeViewDto = new StoreViewDto();
        storeViewDto.setId(store.getId().toString())
                .setBusinessId(store.getBusinessId().toString())
                .setName(store.getName())
                .setAddressProvince(store.getAddressProvince())
                .setAddressCity(store.getAddressCity())
                .setAddressDistrict(store.getAddressDistrict())
                .setAddressStreet(store.getAddressStreet())
                .setAddress(store.getAddress())
                .setArea(String.valueOf((double) store.getArea() / 100))
                .setMainClass(store.getMainClass())
                .setSubClass(store.getSubClass());
        return storeViewDto;
    }

}
